﻿using Microsoft.AspNetCore.Mvc;
using Qy.Scenario;
using System.Threading.Tasks;

namespace Qy.Web.Areas.Home.Controllers;

[Area("Home")]
public class SearchController : Base
{
    private readonly ContentService _contentService;

    public SearchController(ContentService contentService)
    {
        _contentService = contentService;
    }

    [HttpGet]
    //[XssFieldFilter]//防Xss
    public async Task<IActionResult> IndexAsync(string keyword, int page = 1, int limit = 15)
    {
        if (string.IsNullOrEmpty(keyword))return View("../Common/isNull");
        ContentQuery contentQuery = new()
        {
            PageSize = limit,
            PageNum = page,
            KeyWord = keyword
        };
        var pagedList = await _contentService.ContentSearchPageList(contentQuery);
        ViewBag.keyword = keyword;
        return View(pagedList);
    }

}
